<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>敏感字段设置</title>
    <link rel="stylesheet" href="/static/component/pear/css/pear.css"/>
    <meta name="viewport" content="width=device-width,user-scalable=no, initial-scale=1">
</head>
<style>
    .layui-elem-field legend {
        margin-left: 20px;
        padding: 0 10px;
        font-size: 16px;
        font-weight: bold
    }
</style>
<body>
<form class="layui-form formData" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <blockquote class="layui-elem-quote" style="line-height: 24px">
                    <strong>敏感字段设置</strong><br>数据表：{$name}，表名称：{$comment}<br>设置后将实时记录字段更改的日志
                </blockquote>

                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>字段名</th>
                        <th>说明</th>
                        <th>敏感字段</th>
                        <th>数据记录</th>
                    </tr>
                    </thead>
                    <tbody>
                    {foreach $list_field as $k => $v}
                    {if $v['field']!='id' && $v['field']!='is_delete' && $v['field']!='create_time' && $v['field']!='create_id' && $v['field']!='update_time' && $v['field']!='update_id' && $v['field']!='tenant_id'}
                    <tr class="list_data">
                        <td>{$v['field']}</td>
                        <td>{$v['title']}</td>
                        <td><input type="checkbox" name="sensitive_field" lay-skin="primary" value="{$v['field']}"
                                   class="layui-input table-arr" {if $v['sensitive_field']=="1"} checked {/if}>
                        </td>
                        <td><input type="checkbox" name="sensitive_num" lay-skin="primary" value="{$v['field']}"
                                   class="layui-input table-arr" {if $v['sensitive_num']=="1"} checked {/if}>
                        </td>
                        </td>
                    </tr>
                    {/if}

                    {/foreach}
                    </tbody>

                </table>


            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>

<script>
    var $ = layui.jquery;
    layui.use(['http'], function () {
        layui.form.on('submit(save)', function () {
            let sensitive_field = {};
            $("input[name='sensitive_field']:checked").each(function () {
                sensitive_field[$(this).val()] = 1;
            })
            sensitive_field= JSON.stringify(sensitive_field);

            let sensitive_num = {};
            $("input[name='sensitive_num']:checked").each(function () {
                sensitive_num[$(this).val()] = 1;
            })
            sensitive_num= JSON.stringify(sensitive_num);
            layui.http.SendAjax('/ruinuo/database/sensitive/?id={$id}', {sensitive_field: sensitive_field,sensitive_num: sensitive_num}, [], function (res) {
                parent.layer.close(parent.layer.getFrameIndex(window.name));
                return false;
            })
            return false;
        })
    })


</script>

</body>
</html>

